<template>
  <a-table :columns="columns" :dataSource="data">
    <a slot="name" slot-scope="text">{{text}}</a>
    <template slot="operation" slot-scope="text, record">
        <a @click="btnProfile(record.user_id)" href="javascript:;">查看详情</a>
    </template>
  </a-table>
</template>
<script>
  export default {
    name: 'list',
    data() {
      return {
        data: [],
        columns: [
          {
            title: '人员id',
            dataIndex: 'user_id',
            key: 'user_id',
            scopedSlots: { customRender: 'user_id' },
          },
          {
            title: '姓名',
            dataIndex: 'username',
            key: 'username 1',
            ellipsis: true,
          },
          {
            title: '年龄',
            dataIndex: 'age',
            key: 'age 1',
            ellipsis: true,
          },
          {
            title: '操作',
            dataIndex: 'operation',
            scopedSlots: { customRender: 'operation' },
          },
        ]
      };
    },
    created() {
        //数据请求this.$http.post
           this.data =  [
             {
              user_id: 'Xs12',
              username: '六',
              age: '24',
              email: '12@qq.com',
              mobile: '1530000000',
              key: 1
            },
            {
              user_id: 'Xs15',
              username: '六23',
              age: '23',
              email: '124@qq.com',
              mobile: '1530000010',
              key: 2
            }];
    },
    methods: {
        btnProfile(user_id) {
         this.$store.commit('setState', {
           title: '人员详情'
         });

        this.$router.push({
          name: 'profile',
          params: {
            user_id: user_id
          }
        })
      },
    }
  };
</script>
